$(function(){
	bindnamemenu();
	bindtree();
	bindbrand();
	binddetail();
	binddel();
	bindSearch();
	});


function bindbrand(){
	$("#brandList a").click(function(){
		var a = $(this);
		$("#brand_input").val(a.text());
	});
}

function bindtree(){
	var $categoryTree = $("#categoryTree");
	var $categoryInput = $("#categoryInput");
	$("#categoryBtn").click(function(){
		if($categoryTree.css("display")=="none"){
			$categoryTree.css("display","block");
			new Tree('[{id:"a",text:"1alskdfjalslaksdfadskf",childs:[{id:"a1",text:"sdfasdf"}]}]',"categoryTree");
			$categoryTree.find("span").click(bindbreeItem);
		}else{
			$categoryTree.css("display","none");
			closetree();
		}
	});
	$categoryInput.focus(function(){
		var $input = $(this);
		if($input.val()===aTiele.seORNew){
			$input.val("");
		}else{
			$input.select();
		}
		closetree();
	});
	function bindbreeItem(){
		$categoryInput.val($(this).text());
		closetree();
	}
	function closetree(){
		$categoryTree.find("span").unbind();
		$categoryTree.empty();
		$categoryTree.css("display","none");
	}
}

function bindnamemenu(){
	var $searchCommodity = $("#commdityMenu");
	var $commodityInput = $("#commodityInput");
	$("#commodityBtn").click(function(){
		if($searchCommodity.css("display")=="none"){
			$searchCommodity.css("display","block");
			$searchCommodity.append('<ul class="menuitem"><li><a href="#">是大块发生地方块</a></li><li><a href="#">是大块发生地方块</a></li><li><a href="#">是大块发生地方块</a></li><li><a href="#">是大块发生地方块</a></li></ul>');
			$searchCommodity.find("ul li a").click(bindmenuitem);				
		}else{
			$searchCommodity.empty();
			$searchCommodity.css("display","none");
			close();
		}
		
		
		
		
	});
		$commodityInput.focus(function(){
		var $input = $(this);
		if($input.val()===aTiele.seORNew){
			$input.val("");
		}else{
			$input.select();
		}
		close();
	});
	function bindmenuitem(){
		$searchCommodity.find("ul li a").unbind();
		$searchCommodity.empty();
			$("#commodityInput").val($(this).text());
		close();
	}
	
	function close(){
		
			$searchCommodity.css("display","none")
	}
}

//绑定详细按钮
function binddetail(){
	$("#uppinfenshangpin .detail").click(function(){
		alert("详细");
	});
}




